﻿using J.Model;
using J.ProductSet.Application.Command.AggregateCommodityCommand;
using MediatR;
using SqlSugar;

namespace J.ProductSet.Application.CommandHandler.AggregateCommodityCommandHandler
{
    public class AggregateDeletionCommandHandler : IRequestHandler<AggregateDeletionCommand, int>
    {
        private readonly ISqlSugarClient _sqlSugarClient;
        public AggregateDeletionCommandHandler(ISqlSugarClient sqlSugarClient)
        {
            _sqlSugarClient = sqlSugarClient;
        }
        public async Task<int> Handle(AggregateDeletionCommand request, CancellationToken cancellationToken)
        {
            return await _sqlSugarClient.Deleteable<AggregateCommodity>(new AggregateCommodity() { AggregateID = request.AggregateID }).ExecuteCommandAsync();
        }
    }
}
